package cc.rengu.igas.momp.common.dao.impl;

import cc.rengu.igas.momp.common.constant.CommonConstant;
import cc.rengu.igas.momp.common.dao.PlatBizTmpMapper;
import cc.rengu.igas.momp.common.entity.*;
import cc.rengu.igas.momp.common.enums.AuditStatusEnum;
import cc.rengu.igas.momp.common.enums.BizStatusEnum;
import cc.rengu.igas.momp.common.enums.McStatusEnum;
import cc.rengu.igas.momp.common.enums.TableNameEnum;
import cc.rengu.jradp.mods.dbs.Database;
import cc.rengu.oltp.service.common.constant.AppConfigConstant;
import cc.rengu.oltp.service.common.constant.AppParamConstant;
import cc.rengu.oltp.utility.bean.PageInfo;
import cc.rengu.oltp.utility.bean.PageResult;
import cc.rengu.oltp.utility.util.DbsUtil;
import cc.rengu.oltp.utility.util.XmlConfigUtil;
import cc.rengu.oltp.utility.util.XmlTreeUtil;
import cc.rengu.utility.cache.UnifiedCache;
import cc.rengu.utility.log.RgLog;
import cc.rengu.utility.log.RgLogger;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 业务数据临时表数据库操作接口实现
 *
 * @author Jinan Liu
 * @date 2020/3/25 21:42
 */
public class PlatBizTmpMapperImpl implements PlatBizTmpMapper {

    private RgLogger rglog = RgLog.getLogger(this.getClass().getName());
    String dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(AppParamConstant.DATABASE_CONF_NODE, AppConfigConstant.MOMP_POOL_NAME);

    /**
     * @param instId
     * @param mcNo
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMPlatBizTmp>
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/25 21:55
     * @description 获取营销活动机构信息列表数据库操作接口定义
     */
    @Override
    public List<TMPlatBizTmp> selectTmpMcOrgInfo(String instId, String mcNo) throws Exception {
        return null;
    }

    /**
     * @param instId
     * @param mcNo
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMPlatBizTmp>
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/25 21:55
     * @description 获取营销活动商户信息列表数据库操作接口定义
     */
    @Override
    public List<TMPlatBizTmp> selectTmpMcMchntInfo(String instId, String mcNo) throws Exception {
        return null;
    }

    /**
     * @param instId
     * @param mcNo
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMPlatBizTmp>
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/25 21:55
     * @description 获取营销活动时间信息列表数据库操作接口定义
     */
    @Override
    public List<TMPlatBizTmp> selectTmpMcTimeInfo(String instId, String mcNo) throws Exception {
        return null;
    }

    /**
     * @param instId
     * @param mcNo
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMPlatBizTmp>
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/25 21:55
     * @description 获取营销活动用户信息列表数据库操作接口定义
     */
    @Override
    public List<TMPlatBizTmp> selectTmpMcUserInfo(String instId, String mcNo) throws Exception {
        return null;
    }

    /**
     * @param instId
     * @param mcNo
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMPlatBizTmp>
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/25 21:55
     * @description 获取卡券营销活动信息数据库操作接口定义
     */
    @Override
    public List<TMPlatBizTmp> selectTmpMcProductInfo(String instId, String mcNo) throws Exception {
        return null;
    }

    /**
     * @param instId
     * @param mcNo
     * @return cc.rengu.igas.momp.common.entity.TMPlatBizTmp
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/25 21:55
     * @description 获取代理商营销活动信息数据库操作接口定义
     */
    @Override
    public TMPlatBizTmp selectTmpAgentProfitSharingMcInfo(String instId, String mcNo) throws Exception {
        return null;
    }

    /**
     * @param instId
     * @param mcNo
     * @return cc.rengu.igas.momp.common.entity.TMPlatBizTmp
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/25 21:55
     * @description 获取收银员返现营销活动信息数据库操作接口定义
     */
    @Override
    public TMPlatBizTmp selectTmpCashierCashbackMcInfo(String instId, String mcNo) throws Exception {
        return null;
    }

    /**
     * @param instId
     * @param mcNo
     * @return cc.rengu.igas.momp.common.entity.TMPlatBizTmp
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/25 21:55
     * @description 获取卡券营销活动信息数据库操作接口定义
     */
    @Override
    public TMPlatBizTmp selectTmpCouponMcInfo(String instId, String mcNo) throws Exception {
        return null;
    }

    /**
     * @param instId
     * @param mcNo
     * @return cc.rengu.igas.momp.common.entity.TMPlatBizTmp
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/25 21:55
     * @description 获取商户手续费营销活动信息数据库操作接口定义
     */
    @Override
    public TMPlatBizTmp selectTmpMchntFeeDiscountMcInfo(String instId, String mcNo) throws Exception {
        return null;
    }

    /**
     * 获取营销活动基本信息数据库操作接口实现
     * 各类营销活动通用接口
     *
     * @param instId    法人机构号
     * @param mcNo      营销活动编号
     * @param tableName 数据库表名
     * @return cc.rengu.igas.momp.common.entity.TMPlatBizTmp 业务数据临时表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/26 03:11
     */
    @Override
    public TMPlatBizTmp selectTmpMcInfo(String instId, String mcNo, String tableName) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectTmpMcInfo");

        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
        tmPlatBizTmp.setInstId(instId);
        tmPlatBizTmp.setMcNo(mcNo);
        tmPlatBizTmp.setOprTableEname(tableName);

        /* 数据库操作 */
        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, tmPlatBizTmp, tmPlatBizTmp);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("查询法人机构号<{}>营销活动编号<{}>获取<{}>临时表数据失败!<{}>", instId, mcNo, TableNameEnum.getByValue(tableName).getTableNameDesc(), iReturnCode);
            return null;
        }

        return tmPlatBizTmp;
    }

    /**
     * @param instId
     * @param mcNo
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMPlatBizTmp>
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/25 21:55
     * @description 获取代理商营销活动规则信息数据库操作接口定义
     */
    @Override
    public List<TMPlatBizTmp> selectTmpAgentProfitSharingMcRuleInfo(String instId, String mcNo) throws Exception {
        return null;
    }

    /**
     * @param instId
     * @param mcNo
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMPlatBizTmp>
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/25 21:55
     * @description 获取收银员返现营销活动规则信息数据库操作接口定义
     */
    @Override
    public List<TMPlatBizTmp> selectTmpCashierCashbackMcRuleInfo(String instId, String mcNo) throws Exception {
        return null;
    }

    /**
     * @param instId
     * @param mcNo
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMPlatBizTmp>
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/25 21:55
     * @description 获取卡券营销活动规则信息数据库操作接口定义
     */
    @Override
    public List<TMPlatBizTmp> selectTmpCouponMcRuleInfo(String instId, String mcNo) throws Exception {
        return null;
    }

    /**
     * @param instId
     * @param mcNo
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMPlatBizTmp>
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/25 21:54
     * @description 获取商户手续费减免营销活动规则信息数据库操作接口定义
     */
    @Override
    public List<TMPlatBizTmp> selectTmpMchntFeeDiscountMcRuleInfo(String instId, String mcNo) throws Exception {
        return null;
    }

    /**
     * @param instId
     * @param mcNo
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMPlatBizTmp>
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/25 21:54
     * @description 获取减免营销活动规则信息数据库操作接口定义
     */
    @Override
    public List<TMPlatBizTmp> selectTmpMoneyOffMcRuleInfo(String instId, String mcNo) throws Exception {
        return null;
    }

    /**
     * 使用主键更新代理商营销活动审批状态数据库操作接口实现
     *
     * @param instId      法人机构号
     * @param mcNo        营销活动编号
     * @param auditStatus
     * @return int
     * @throws Exception
     * @author Jinan Liu
     * @date 2020/4/6 23:13
     */
    @Override
    public int updateAgentProfitSharingMcAuditStatusByPrimaryKey(String instId, String mcNo, String auditStatus) throws Exception {
        return 0;
    }

    /**
     * 使用主键更新收银员返现类营销活动审批状态数据库操作接口实现
     *
     * @param instId      法人机构号
     * @param mcNo        营销活动编号
     * @param auditStatus
     * @return int
     * @throws Exception
     * @author Jinan Liu
     * @date 2020/4/6 23:13
     */
    @Override
    public int updateCashierCashbackMcAuditStatusByPrimaryKey(String instId, String mcNo, String auditStatus) throws Exception {
        return 0;
    }

    /**
     * 使用主键更新卡券类营销活动审批状态数据库操作接口实现
     *
     * @param instId      法人机构号
     * @param mcNo        营销活动编号
     * @param auditStatus
     * @return int
     * @throws Exception
     * @author Jinan Liu
     * @date 2020/4/6 23:13
     */
    @Override
    public int updateCouponMcAuditStatusByPrimaryKey(String instId, String mcNo, String auditStatus) throws Exception {
        return 0;
    }

    /**
     * 使用主键更新商户手续费优惠类营销活动审批状态数据库操作接口实现
     *
     * @param instId      法人机构号
     * @param mcNo        营销活动编号
     * @param auditStatus
     * @return int
     * @throws Exception
     * @author Jinan Liu
     * @date 2020/4/6 23:13
     */
    @Override
    public int updateMchntFeeDiscountMcAuditStatusByPrimaryKey(String instId, String mcNo, String auditStatus) throws Exception {
        return 0;
    }

    /**
     * 使用主键更新卡券类营销活动审批状态数据库操作接口实现
     *
     * @param instId         法人机构号
     * @param mcNo           营销活动编号
     * @param auditStatus    审批状态
     * @param newAuditStatus 新审批状态
     * @param bizStatus      状态
     * @param mcStatus       营销活动状态
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/6 22:17
     */
    @Override
    public int updateTmpMcAuditStatusByPrimaryKey(String instId, String mcNo, String auditStatus, String newAuditStatus, String bizStatus, String mcStatus) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateTmpMcAuditStatusByPrimaryKey");

        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
        tmPlatBizTmp.setInstId(instId);
        tmPlatBizTmp.setMcNo(mcNo);
        tmPlatBizTmp.setBizStatus(bizStatus);
        tmPlatBizTmp.setMcStatus(mcStatus);
        tmPlatBizTmp.setAuditStatus(auditStatus);
        tmPlatBizTmp.setRemark1(newAuditStatus);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新临时表中草稿状态法人机构号<{}>营销活动编号<{}>的营销活动信息审批状态失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    @Override
    public int updateTmpMcInfoAuditStatusByPrimaryKey(String instId, String mcNo, String tableName, String auditStatus, String newAuditStatus, String bizStatus, String mcStatus) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateTmpMcInfoAuditStatusByPrimaryKey");

        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
        tmPlatBizTmp.setInstId(instId);
        tmPlatBizTmp.setMcNo(mcNo);
        tmPlatBizTmp.setBizStatus(bizStatus);
        tmPlatBizTmp.setMcStatus(mcStatus);
        tmPlatBizTmp.setAuditStatus(auditStatus);
        tmPlatBizTmp.setRemark1(newAuditStatus);
        tmPlatBizTmp.setOprTableEname(tableName);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新临时表中草稿状态法人机构号<{}>营销活动编号<{}>的营销活动信息审批状态失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    @Override
    public int updateTmpMcOtherAuditStatusByPrimaryKey(String instId, String mcNo, String tableName, String auditStatus, String newAuditStatus, String bizStatus, String mcStatus) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateTmpMcOtherAuditStatusByPrimaryKey");

        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
        tmPlatBizTmp.setInstId(instId);
        tmPlatBizTmp.setMcNo(mcNo);
        tmPlatBizTmp.setBizStatus(bizStatus);
        tmPlatBizTmp.setMcStatus(mcStatus);
        tmPlatBizTmp.setAuditStatus(auditStatus);
        tmPlatBizTmp.setRemark1(newAuditStatus);
        tmPlatBizTmp.setOprTableEname(tableName);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新临时表中草稿状态法人机构号<{}>营销活动编号<{}>的营销活动信息审批状态失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }


    /**
     * 使用主键更新商户手续费优惠类营销活动审批状态数据库操作接口实现
     *
     * @param instId         法人机构号
     * @param mcNo           营销活动编号
     * @param auditStatus    审批状态
     * @param newAuditStatus 新审批状态
     * @param bizStatus      状态
     * @param mcStatus       营销活动状态
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/6 22:17
     */
    @Override
    public int updateTmpMfdMcAuditStatusByPrimaryKey(String instId, String mcNo, String auditStatus, String newAuditStatus, String bizStatus, String mcStatus) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateTmpMfdMcAuditStatusByPrimaryKey");

        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
        tmPlatBizTmp.setInstId(instId);
        tmPlatBizTmp.setMcNo(mcNo);
        tmPlatBizTmp.setBizStatus(bizStatus);
        tmPlatBizTmp.setMcStatus(mcStatus);
        tmPlatBizTmp.setAuditStatus(auditStatus);
        tmPlatBizTmp.setRemark1(newAuditStatus);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新临时表中草稿状态法人机构号<{}>营销活动编号<{}>的营销活动信息审批状态失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 删除临时表草稿状态营销活动数据数据库操作接口实现
     *
     * @param instId 法人机构号
     * @param mcNo   营销活动编号
     * @return int
     * @throws Exception
     * @author Jinan Liu
     * @date 2020/4/7 01:28
     */
    @Override
    public int deleteTmpMcDataByMcNo(String instId, String mcNo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "deleteTmpMcDataByMcNo");

        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
        tmPlatBizTmp.setInstId(instId);
        tmPlatBizTmp.setMcNo(mcNo);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode && Database.DBS_NOT_FOUND != iReturnCode) {
            rglog.error("根据条件删除法人机构号<{}>营销活动编号<{}>所有临时表数据失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return CommonConstant.PROCESS_FAILED;
        }

        return CommonConstant.PROCESS_SUCCESS;
    }

    /**
     * 删除临时表营销活动相关数据数据库操作接口定义
     * 保留营销活动商户列表
     *
     * @param instId 法人机构号
     * @param mcNo   营销活动编号
     * @return int 返回码
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/6/4 20:27
     */
    @Override
    public int deleteTmpMcDataRetainMchntListByMcNo(String instId, String mcNo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "deleteTmpMcDataRetainMchntListByMcNo");

        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
        tmPlatBizTmp.setInstId(instId);
        tmPlatBizTmp.setMcNo(mcNo);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode && Database.DBS_NOT_FOUND != iReturnCode) {
            rglog.error("根据条件删除法人机构号<{}>营销活动编号<{}>所有临时表数据失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return CommonConstant.PROCESS_FAILED;
        }

        return CommonConstant.PROCESS_SUCCESS;
    }

    /**
     * 使用营销活动编号和营销活动审批状态更新营销活动状态、审批状态和状态数据库操作接口实现
     *
     * @param instId         法人机构号
     * @param mcNo           营销活动编号
     * @param bizStatus      状态
     * @param mcStatus       营销活动状态
     * @param newAuditStatus 新审批状态
     * @param oldAuditStatus 老审批状态
     * @param oprId          操作员ID
     * @param timeStamp      时间戳
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/7 01:44
     */
    @Override
    public int updateTmpMcAllStatusByMcNoAndAuditStatus(String instId, String mcNo, String bizStatus, String mcStatus, String newAuditStatus, String oldAuditStatus, String oprId, String timeStamp) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateTmpMcAllStatusByMcNoAndAuditStatus");

        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
        tmPlatBizTmp.setInstId(instId);
        tmPlatBizTmp.setMcNo(mcNo);
        tmPlatBizTmp.setBizStatus(bizStatus);
        tmPlatBizTmp.setMcStatus(mcStatus);
        tmPlatBizTmp.setAuditStatus(newAuditStatus);
        tmPlatBizTmp.setRemark1(oldAuditStatus);
        tmPlatBizTmp.setLastOprId(oprId);
        tmPlatBizTmp.setLastUpdateTime(timeStamp);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新法人机构号<{}>营销活动编号<{}>的减免类营销活动基本信息的临时表的发布拒绝数据失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 使用营销活动编号和营销活动审批状态更新临时表营销活动信息接口定义
     *
     * @param instId         法人机构号
     * @param mcNo           营销活动编号
     * @param bizStatus      状态
     * @param mcStatus       营销活动状态
     * @param newAuditStatus 新审批状态
     * @param oldAuditStatus 老审批状态
     * @param oprId          操作员ID
     * @param timeStamp      时间戳
     * @return int 返回码
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2021/6/10 17:43
     */
    @Override
    public int updateTmpMcInfoStatusByMcNoAndAuditStatus(String instId, String mcNo, String tableName, String bizStatus, String mcStatus, String newAuditStatus, String oldAuditStatus, String oprId, String timeStamp) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]，sql = updateTmpMcInfoStatusByMcNoAndAuditStatus", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateTmpMcInfoStatusByMcNoAndAuditStatus");

        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
        tmPlatBizTmp.setInstId(instId);
        tmPlatBizTmp.setMcNo(mcNo);
        tmPlatBizTmp.setBizStatus(bizStatus);
        tmPlatBizTmp.setMcStatus(mcStatus);
        tmPlatBizTmp.setAuditStatus(newAuditStatus);
        tmPlatBizTmp.setRemark1(oldAuditStatus);
        tmPlatBizTmp.setLastOprId(oprId);
        tmPlatBizTmp.setLastUpdateTime(timeStamp);
        tmPlatBizTmp.setOprTableEname(tableName);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新法人机构号<{}>营销活动编号<{}>的减免类营销活动基本信息的临时表的发布拒绝数据失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 使用营销活动编号和营销活动审批状态更新临时表营销活动信息之外的其他表数据接口定义
     *
     * @param instId         法人机构号
     * @param mcNo           营销活动编号
     * @param bizStatus      状态
     * @param mcStatus       营销活动状态
     * @param newAuditStatus 新审批状态
     * @param oldAuditStatus 老审批状态
     * @param oprId          操作员ID
     * @param timeStamp      时间戳
     * @return int 返回码
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2021/6/10 17:43
     */
    @Override
    public int updateTmpMcOtherStatusByMcNoAndAuditStatus(String instId, String mcNo, String tableName, String bizStatus, String mcStatus, String newAuditStatus, String oldAuditStatus, String oprId, String timeStamp) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]，sql = updateTmpMcOtherStatusByMcNoAndAuditStatus", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateTmpMcOtherStatusByMcNoAndAuditStatus");

        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
        tmPlatBizTmp.setInstId(instId);
        tmPlatBizTmp.setMcNo(mcNo);
        tmPlatBizTmp.setBizStatus(bizStatus);
        tmPlatBizTmp.setMcStatus(mcStatus);
        tmPlatBizTmp.setAuditStatus(newAuditStatus);
        tmPlatBizTmp.setRemark1(oldAuditStatus);
        tmPlatBizTmp.setLastOprId(oprId);
        tmPlatBizTmp.setLastUpdateTime(timeStamp);
        tmPlatBizTmp.setOprTableEname(tableName);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新法人机构号<{}>营销活动编号<{}>的减免类营销活动基本信息的临时表的发布拒绝数据失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 使用营销活动编号和营销活动审批状态更新营销活动审批状态数据库操作接口实现
     *
     * @param instId         法人机构号
     * @param mcNo           营销活动编号
     * @param newAuditStatus 新审批状态
     * @param oldAuditStatus 老审批状态
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/7 01:44
     */
    @Override
    public int updateTmpMcAuditStatusByMcNoAndAuditStatus(String instId, String mcNo, String newAuditStatus, String oldAuditStatus) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateTmpMcAuditStatusByMcNoAndAuditStatus");

        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
        tmPlatBizTmp.setInstId(instId);
        tmPlatBizTmp.setMcNo(mcNo);
        tmPlatBizTmp.setAuditStatus(newAuditStatus);
        tmPlatBizTmp.setRemark1(oldAuditStatus);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新法人机构号<{}>营销活动编号<{}>的减免类营销活动基本信息的临时表的发布拒绝数据失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 进行中营销活动添加商户数据库操作接口实现
     *
     * @param tmPlatBizTmpList
     * @return int
     * @throws Exception
     * @author Jinan Liu
     * @date 2020/4/9 11:45
     */
    @Override
    public int insertMchntDataForUnderwayMc(List<TMPlatBizTmp> tmPlatBizTmpList) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "insertSingleRecordByBank");

        for (TMPlatBizTmp tmPlatBizTmp : tmPlatBizTmpList) {

            int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
            if (Database.DBS_SUCCESS != iReturnCode) {
                rglog.error("机构号<{}>营销活动编号<{}>插入商户信息失败!", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo());
                return iReturnCode;
            }
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 减免类营销活动插入临时表数据库操作接口实现
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/22 15:34
     */
    @Override
    public int insertMcInfoByBank(TMPlatBizTmp tmPlatBizTmp) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "insertSingleRecordByBank");

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("将法人机构号<{}>营销活动编号<{}>的营销活动信息插入临时表失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 营销活动除营销活动基本信息外的数据的列表插入临时表数据库操作接口实现
     *
     * @param tmPlatBizTmpList 业务数据临时表
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 22:15
     */
    @Override
    public int insertMultiMcDetialInfoByBank(List<TMPlatBizTmp> tmPlatBizTmpList) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "insertSingleRecordByBank");

        for (TMPlatBizTmp tmPlatBizTmp : tmPlatBizTmpList) {

            int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
            if (Database.DBS_SUCCESS != iReturnCode) {
                rglog.error("将法人机构号<{}>营销活动编号<{}>的机构编号<{}>的营销活动机构信息插入临时表失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), tmPlatBizTmp.getOrgId(), iReturnCode);
                return iReturnCode;
            }
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 营销活动除营销活动基本信息外的数据的列表插入临时表数据库操作接口实现
     *
     * @param tmPlatBizTmpList 业务数据临时表
     * @return int 返回码
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2021/6/7 16:15
     */
    @Override
    public int deleteMultiMcMchntListByBank(List<TMPlatBizTmp> tmPlatBizTmpList) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "deleteMultiMcMchntListByBank");

        for (TMPlatBizTmp tmPlatBizTmp : tmPlatBizTmpList) {

            int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
            if (Database.DBS_SUCCESS != iReturnCode) {
                rglog.error("将法人机构号<{}>营销活动编号<{}>的机构编号<{}>的营销活动机构信息插入临时表失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), tmPlatBizTmp.getOrgId(), iReturnCode);
                return iReturnCode;
            }
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 减免类营销活动发布更新状态数据库操作接口实现
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/25 22:30
     */
    @Override
    public int updateSingleMcInfoForPublishing(TMPlatBizTmp tmPlatBizTmp) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateSingleMcInfoForPublishing");

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("将法人机构号<{}>营销活动编号<{}>的营销活动信息插入临时表失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 取营销活动商户规则列表信息
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMPlatBizTmp> 业务数据临时表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/25 23:04
     */
    @Override
    public List<TMPlatBizTmp> selectNewAddedMchntInfoForPublishing(TMPlatBizTmp tmPlatBizTmp) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectNewAddedMchntInfoForPublishing");

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (null == objectList || objectList.isEmpty()) {
            rglog.error("查询机构<{}>营销活动<{}>待发布商户规则数据失败!", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo());
            return null;
        }

        return objectList.stream().map(item -> (TMPlatBizTmp) (item)).collect(Collectors.toList());
    }

    @Override
    public PageResult selectNewAddedMchntInfoForPublishing(TMPlatBizTmp tmPlatBizTmp, PageInfo pageInfo) throws Exception {
        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectNewAddedMchntInfoForPublishing");

        return dbsUtil.dbsFetchPageListData(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class, pageInfo);
    }

    /**
     * 减免类营销活动发布拒绝更新状态数据库操作接口实现
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/26 01:06
     */
    @Override
    public int updateMcAuditStatusForPublishingRefusal(TMPlatBizTmp tmPlatBizTmp) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateMcAuditStatusForPublishingRefusal");

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新法人机构号<{}>营销活动编号<{}>的减免类营销活动基本信息的临时表的发布拒绝数据失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 启用已暂停营销活动数据库操作接口定义
     * 目前支持减免类\卡券类和收银员返现类营销活动
     * 启用已暂停\暂停进行中\强制终止进行中营销活动时使用
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/26 01:35
     */
    @Override
    public int updatePausedMcForEnabling(TMPlatBizTmp tmPlatBizTmp) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updatePausedMcForEnabling");

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("启用已暂停的法人机构号<{}>营销活动编号<{}>的减免类营销活动更新临时表数据失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 银行审批员查询所有商户手续费优惠类营销活动信息数据库操作接口实现
     *
     * @param mfdMcListInfoInObj 商户手续费优惠类营销活动列表查询使用实体类入参
     * @param pageInfo           数据库操作分页实体类
     * @return cc.rengu.oltp.utility.bean.PageResult 查询结果列表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 12:09
     */
    @Override
    public PageResult selectMfdMcListInfoByBankAuditRole(MfdMcListInfoInObj mfdMcListInfoInObj, PageInfo pageInfo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMfdMcListInfoByBankAuditRole");

        return dbsUtil.dbsFetchPageListData(sqlStr, mfdMcListInfoInObj, TMPlatBizTmp.class, pageInfo);
    }

    /**
     * 银行审批员查询所有卡券类营销活动信息数据库操作接口实现
     *
     * @param cpMcListInfoInObj 卡券类营销活动列表查询使用实体类入参
     * @param pageInfo          数据库操作分页实体类
     * @return cc.rengu.oltp.utility.bean.PageResult 查询结果列表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 12:09
     */
    @Override
    public PageResult selectCouponMcListInfoByBankAuditRole(CpMcListInfoInObj cpMcListInfoInObj, PageInfo pageInfo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectCouponMcListInfoByBankAuditRole");

        return dbsUtil.dbsFetchPageListData(sqlStr, cpMcListInfoInObj, TMPlatBizTmp.class, pageInfo);
    }

    /**
     * 银行审批员查询所有减免类营销活动信息数据库操作接口实现
     *
     * @param moMcListInfoInObj 营销活动列表查询使用实体类入参
     * @param pageInfo          数据库操作分页实体类
     * @return cc.rengu.oltp.utility.bean.PageResult 查询结果列表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 12:09
     */
    @Override
    public PageResult selectMoneyOffMcListInfoByBankAuditRole(MoMcListInfoInObj moMcListInfoInObj, PageInfo pageInfo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMoneyOffMcListInfoByBankAuditRole");

        return dbsUtil.dbsFetchPageListData(sqlStr, moMcListInfoInObj, TMPlatBizTmp.class, pageInfo);
    }

    /**
     * 银行审批员查询所有代理商分润营销活动信息数据库操作接口实现
     *
     * @param apsMcListInfoInObj 营销活动列表查询使用实体类入参
     * @param pageInfo           数据库操作分页实体类
     * @return cc.rengu.oltp.utility.bean.PageResult 查询结果列表
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/5/28 12:09
     */
    @Override
    public PageResult selectApsMcListInfoByBankAuditRole(ApsMcListInfoInObj apsMcListInfoInObj, PageInfo pageInfo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectApsMcListInfoByBankAuditRole");

        return dbsUtil.dbsFetchPageListData(sqlStr, apsMcListInfoInObj, ApsMcListInfoOutObj.class, pageInfo);
    }

    /**
     * 银行审批员查询所有卡券类营销活动详细信息数据库操作接口实现
     *
     * @param cpMcListInfoInObj 卡券类营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMPlatBizTmp 业务数据临时表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:27
     */
    @Override
    public TMPlatBizTmp selectCouponMcDetailInfoByBankAuditRole(CpMcListInfoInObj cpMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectCouponMcDetailInfoByBankAuditRole");

        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, cpMcListInfoInObj, tmPlatBizTmp);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取减免类营销活动信息失败!<{}>", cpMcListInfoInObj.getInstId(), cpMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmPlatBizTmp;
    }

    /**
     * 银行审批员查询所有商户手续费优惠类营销活动详细信息数据库操作接口实现
     *
     * @param mfdMcListInfoInObj 商户手续费优惠类营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMPlatBizTmp 业务数据临时表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:27
     */
    @Override
    public TMPlatBizTmp selectMfdMcDetailInfoByBankAuditRole(MfdMcListInfoInObj mfdMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMfdMcDetailInfoByBankAuditRole");

        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, mfdMcListInfoInObj, tmPlatBizTmp);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取减免类营销活动信息失败!<{}>", mfdMcListInfoInObj.getInstId(), mfdMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmPlatBizTmp;
    }

    /**
     * 银行审批员查询所有减免类营销活动详细信息数据库操作接口实现
     *
     * @param moMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMPlatBizTmp 业务数据临时表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:27
     */
    @Override
    public TMPlatBizTmp selectMoneyOffMcDetailInfoByBankAuditRole(MoMcListInfoInObj moMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMoneyOffMcDetailInfoByBankAuditRole");

        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, moMcListInfoInObj, tmPlatBizTmp);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取减免类营销活动信息失败!<{}>", moMcListInfoInObj.getInstId(), moMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmPlatBizTmp;
    }

    /**
     * 银行审批员查询所有代理商分润营销活动详细信息数据库操作接口实现
     *
     * @param moMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMPlatBizTmp 业务数据临时表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:27
     */
    @Override
    public TMPlatBizTmp selectApsMcDetailInfoByBankAuditRole(MoMcListInfoInObj moMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectApsMcDetailInfoByBankAuditRole");

        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, moMcListInfoInObj, tmPlatBizTmp);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取代理商分润营销活动信息失败!<{}>", moMcListInfoInObj.getInstId(), moMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmPlatBizTmp;
    }

    /**
     * 银行审批员查询指定营销活动所有减免类营销活动数据数据库操作接口实现
     *
     * @param moMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMPlatBizTmp 业务数据临时表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:27
     */
    @Override
    public List<TMPlatBizTmp> selectSingleMcAllDetailInfoByBankAuditRole(MoMcListInfoInObj moMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectSingleMcAllDetailInfoByBankAuditRole");

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, moMcListInfoInObj, TMPlatBizTmp.class);
        if (null == objectList || objectList.isEmpty()) {
            rglog.error("查询机构<{}>营销活动<{}>所有待审批数据失败!", moMcListInfoInObj.getInstId(), moMcListInfoInObj.getMcNo());
            return null;
        }

        return objectList.stream().map(item -> (TMPlatBizTmp) (item)).collect(Collectors.toList());
    }


    /**
     * 银行审批员查询指定营销活动所有减免类营销活动数据数据库操作接口定义
     * 分页查询接口
     *
     * @param moMcListInfoInObj 营销活动列表查询使用实体类入参
     * @param pageInfo          分页信息入参
     * @return cc.rengu.oltp.utility.bean.PageResult 分页数据
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2021/8/22 13:27
     */
    public PageResult selectSingleMcAllDetailInfoByBankAuditRole(MoMcListInfoInObj moMcListInfoInObj, PageInfo pageInfo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectSingleMcAllDetailInfoByBankAuditRole");

        return dbsUtil.dbsFetchPageListData(sqlStr, moMcListInfoInObj, TMPlatBizTmp.class, pageInfo);
    }

    /**
     * 银行审批员查询指定营销活动所有减免类营销活动数据数据库操作接口实现
     *
     * @param moMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMPlatBizTmp 业务数据临时表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:27
     */
    @Override
    public List<TMPlatBizTmp> selectSingleMcDetailInfoNoMchntByBankAuditRole(MoMcListInfoInObj moMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectSingleMcDetailInfoNoMchntByBankAuditRole");

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, moMcListInfoInObj, TMPlatBizTmp.class);
        if (null == objectList || objectList.isEmpty()) {
            rglog.error("查询机构<{}>营销活动<{}>所有待审批数据失败!", moMcListInfoInObj.getInstId(), moMcListInfoInObj.getMcNo());
            return null;
        }

        return objectList.stream().map(item -> (TMPlatBizTmp) (item)).collect(Collectors.toList());
    }

    /**
     * 删错指定营销活动编号的所有草稿状态的数据数据数据库操作接口实现
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 23:04
     */
    @Override
    public int deleteAllDraftMcInfoByBank(TMPlatBizTmp tmPlatBizTmp) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "deleteAllDraftMcInfoByBank");

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode && Database.DBS_NOT_FOUND != iReturnCode) {
            rglog.error("根据条件删除法人机构号<{}>营销活动编号<{}>所有临时表数据失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return CommonConstant.PROCESS_FAILED;
        }

        return CommonConstant.PROCESS_SUCCESS;
    }

    /**
     * 营销活动列表临时数据查询数据库操作接口实现
     *
     * @param platBizTmp 业务数据临时表
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMPlatBizTmp> 业务数据临时表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/30 12:30
     */
    @Override
    public List<TMPlatBizTmp> selectTmpMcListInfo(TMPlatBizTmp platBizTmp) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectTmpMcListInfo");

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, platBizTmp, TMPlatBizTmp.class);
        if (null == objectList || objectList.isEmpty()) {
            rglog.error("获取营销活动列表信息失败!");
            return null;
        }

        return objectList.stream().map(item -> (TMPlatBizTmp) (item)).collect(Collectors.toList());
    }

    /**
     * 银行审批员查询所有收银员返现活动详细信息数据库操作接口实现
     *
     * @param ccbMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMPlatBizTmp 业务数据临时表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:27
     */
    @Override
    public TMPlatBizTmp selectCashDetailInfoByBankAuditRole(CcbMcListInfoInObj ccbMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectCcbMcDetailInfoByBankAuditRole");

        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, ccbMcListInfoInObj, tmPlatBizTmp);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取减免类营销活动信息失败!<{}>", ccbMcListInfoInObj.getInstId(), ccbMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmPlatBizTmp;
    }

    /**
     * 银行审批员查询所有收银员返现活动信息数据库操作接口实现
     *
     * @param ccbMcListInfoInObj 营销活动列表查询使用实体类入参
     * @param pageInfo           数据库操作分页实体类
     * @return cc.rengu.oltp.utility.bean.PageResult 查询结果列表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 12:09
     */
    @Override
    public PageResult selectCcbMcListInfoByBankAuditRole(CcbMcListInfoInObj ccbMcListInfoInObj, PageInfo pageInfo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMoneyOffMcListInfoByBankAuditRole");

        return dbsUtil.dbsFetchPageListData(sqlStr, ccbMcListInfoInObj, TMPlatBizTmp.class, pageInfo);
    }

    /**
     * 银行审批员查询指定营销活动所有收银员返现吗活动数据数据库操作接口实现
     *
     * @param ccbMcListInfoInObj 收银员返现活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMPlatBizTmp 业务数据临时表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:27
     */
    @Override
    public List<TMPlatBizTmp> selectCashierDetailInfoByBankAuditRole(CcbMcListInfoInObj ccbMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectSingleMcAllDetailInfoByBankAuditRole");

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, ccbMcListInfoInObj, TMPlatBizTmp.class);
        if (null == objectList || objectList.isEmpty()) {
            rglog.error("查询机构<{}>营销活动<{}>所有待审批数据失败!", ccbMcListInfoInObj.getInstId(), ccbMcListInfoInObj.getMcNo());
            return null;
        }

        return objectList.stream().map(item -> (TMPlatBizTmp) (item)).collect(Collectors.toList());
    }

    /**
     * 使用主键更新临时表各营销活动状态数据库操作接口实现
     *
     * @param instId         法人机构号
     * @param mcNo           营销活动编号
     * @param auditStatus    审批状态
     * @param newAuditStatus 新审批状态
     * @param bizStatus      状态
     * @param newBizStatus   新状态
     * @param newMcStatus    新营销活动状态
     * @return int 返回码
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/6/14 22:17
     */
    @Override
    public int updateTmpAllStatusByPrimaryKey(String instId, String mcNo, String auditStatus, String newAuditStatus,
                                              String bizStatus, String newBizStatus, String mcStatus, String newMcStatus) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompUpdateTmpAllStatusByPrimaryKey");

        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
        tmPlatBizTmp.setInstId(instId);
        tmPlatBizTmp.setMcNo(mcNo);
        tmPlatBizTmp.setBizStatus(bizStatus);
        tmPlatBizTmp.setMcStatus(mcStatus);
        tmPlatBizTmp.setAuditStatus(auditStatus);
        tmPlatBizTmp.setRemark1(newAuditStatus);
        tmPlatBizTmp.setRemark2(newBizStatus);
        tmPlatBizTmp.setRemark3(newMcStatus);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新临时表中草稿状态法人机构号<{}>营销活动编号<{}>的营销活动信息各状态失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 使用营销活动编号和营销活动审批状态更新营销活动状态、审批状态和状态以及审批拒绝原因数据库操作接口定义
     *
     * @param instId         法人机构号
     * @param mcNo           营销活动编号
     * @param tmPlatBizTmp   原临时表数据
     * @param oldAuditStatus 老审批状态
     * @param oprId          操作员ID
     * @param timeStamp      时间戳
     * @return int 返回码
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/7/4
     */
    @Override
    public int updateTmpMcInfoByMcNoAndAuditStatus(String instId, String mcNo, TMPlatBizTmp tmPlatBizTmp, String oldAuditStatus,
                                                   String oprId, String timeStamp) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompUpdateTmpMcInfoByMcNoAndAuditStatus");

        TMPlatBizTmp newTMPlatBizTmp = new TMPlatBizTmp();
        newTMPlatBizTmp.setInstId(instId);
        newTMPlatBizTmp.setMcNo(mcNo);
        newTMPlatBizTmp.setBizStatus(tmPlatBizTmp.getBizStatus());
        newTMPlatBizTmp.setMcStatus(tmPlatBizTmp.getMcStatus());
        newTMPlatBizTmp.setAuditStatus(tmPlatBizTmp.getAuditStatus());
        newTMPlatBizTmp.setRemark1(oldAuditStatus);
        newTMPlatBizTmp.setAuditRefuseReason(tmPlatBizTmp.getAuditRefuseReason());
        newTMPlatBizTmp.setLastOprId(oprId);
        newTMPlatBizTmp.setLastUpdateTime(timeStamp);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, newTMPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新法人机构号<{}>营销活动编号<{}>的营销活动基本信息的临时表数据失败!<{}>", newTMPlatBizTmp.getInstId(), newTMPlatBizTmp.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    @Override
    public int updateTmpMcOtherInfoByMcNoAndAuditStatus(String instId, String mcNo, String tableName, TMPlatBizTmp tmPlatBizTmp, String oldAuditStatus,
                                                        String oprId, String timeStamp) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompUpdateTmpMcOtherInfoByMcNoAndAuditStatus");

        TMPlatBizTmp newTMPlatBizTmp = new TMPlatBizTmp();
        newTMPlatBizTmp.setInstId(instId);
        newTMPlatBizTmp.setMcNo(mcNo);
        newTMPlatBizTmp.setBizStatus(tmPlatBizTmp.getBizStatus());
        newTMPlatBizTmp.setMcStatus(tmPlatBizTmp.getMcStatus());
        newTMPlatBizTmp.setAuditStatus(tmPlatBizTmp.getAuditStatus());
        newTMPlatBizTmp.setRemark1(oldAuditStatus);
        newTMPlatBizTmp.setAuditRefuseReason(tmPlatBizTmp.getAuditRefuseReason());
        newTMPlatBizTmp.setLastOprId(oprId);
        newTMPlatBizTmp.setLastUpdateTime(timeStamp);
        newTMPlatBizTmp.setOprTableEname(tableName);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, newTMPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新法人机构号<{}>营销活动编号<{}>的营销活动基本信息的临时表数据失败!<{}>", newTMPlatBizTmp.getInstId(), newTMPlatBizTmp.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    @Override
    public int updateTmpMcCCBInfoByMcNoAndAuditStatus(String instId, String mcNo, String tableName, TMPlatBizTmp tmPlatBizTmp, String oldAuditStatus,
                                                      String oprId, String timeStamp) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompUpdateTmpMcCCBInfoByMcNoAndAuditStatus");

        TMPlatBizTmp newTMPlatBizTmp = new TMPlatBizTmp();
        newTMPlatBizTmp.setInstId(instId);
        newTMPlatBizTmp.setMcNo(mcNo);
        newTMPlatBizTmp.setBizStatus(tmPlatBizTmp.getBizStatus());
        newTMPlatBizTmp.setMcStatus(tmPlatBizTmp.getMcStatus());
        newTMPlatBizTmp.setAuditStatus(tmPlatBizTmp.getAuditStatus());
        newTMPlatBizTmp.setRemark1(oldAuditStatus);
        newTMPlatBizTmp.setAuditRefuseReason(tmPlatBizTmp.getAuditRefuseReason());
        newTMPlatBizTmp.setLastOprId(oprId);
        newTMPlatBizTmp.setLastUpdateTime(timeStamp);
        newTMPlatBizTmp.setOprTableEname(tableName);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, newTMPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新法人机构号<{}>营销活动编号<{}>的营销活动基本信息的临时表数据失败!<{}>", newTMPlatBizTmp.getInstId(), newTMPlatBizTmp.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 使用营销活动编号和营销活动审批状态更新营销活动状态、审批状态和状态以及审批拒绝原因数据库操作接口定义
     *
     * @param instId         法人机构号
     * @param mcNo           营销活动编号
     * @param tmPlatBizTmp   原临时表数据
     * @param oldAuditStatus 老审批状态
     * @param oprId          操作员ID
     * @param timeStamp      时间戳
     * @return int 返回码
     * @throws Exception 异常信息
     * @author JL PANG
     * @date 2020/7/4
     */
    @Override
    public int updataTMPlatBizByinstIdMcNoTableNameAuditStatus(String instId, String mcNo, TMPlatBizTmp tmPlatBizTmp, String oldAuditStatus,
                                                               String oprId, String timeStamp) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updataTMPlatBizByinstIdMcNoTableNameAuditStatus");

        TMPlatBizTmp newTMPlatBizTmp = new TMPlatBizTmp();
        newTMPlatBizTmp.setInstId(instId);
        newTMPlatBizTmp.setMcNo(mcNo);
        newTMPlatBizTmp.setBizStatus(tmPlatBizTmp.getBizStatus());
        newTMPlatBizTmp.setMcStatus(tmPlatBizTmp.getMcStatus());
        newTMPlatBizTmp.setAuditStatus(tmPlatBizTmp.getAuditStatus());
        newTMPlatBizTmp.setRemark1(oldAuditStatus);
        newTMPlatBizTmp.setAuditRefuseReason(tmPlatBizTmp.getAuditRefuseReason());
        newTMPlatBizTmp.setLastOprId(oprId);
        newTMPlatBizTmp.setLastUpdateTime(timeStamp);
        newTMPlatBizTmp.setOprTableCname(tmPlatBizTmp.getOprTableCname());
        newTMPlatBizTmp.setOprTableEname(tmPlatBizTmp.getOprTableEname());

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, newTMPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新法人机构号<{}>营销活动编号<{}>的营销活动基本信息的临时表数据失败!<{}>", newTMPlatBizTmp.getInstId(), newTMPlatBizTmp.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 营销活动除营销活动基本信息外的数据的列表插入临时表数据库操作接口实现
     *
     * @param tmPlatBizTmpList 业务数据临时表
     * @return int 返回码
     * @throws Exception 异常信息
     * @author JL PANG
     * @date 2020/5/28 22:15
     */
    @Override
    public int updataTMPlatBizByList(List<TMPlatBizTmp> tmPlatBizTmpList, String oprType) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updataTMPlatBizByinstIdMcNoTableNameAuditStatus");
        if (oprType.equals("publish")) {
            TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
            tmPlatBizTmp.setInstId(tmPlatBizTmpList.get(CommonConstant.ZERO).getInstId());
            tmPlatBizTmp.setMcNo(tmPlatBizTmpList.get(CommonConstant.ZERO).getMcNo());
            tmPlatBizTmp.setLastOprId(tmPlatBizTmpList.get(CommonConstant.ZERO).getLastOprId());
            tmPlatBizTmp.setLastUpdateTime(tmPlatBizTmpList.get(CommonConstant.ZERO).getLastUpdateTime());
            tmPlatBizTmp.setBizStatus(BizStatusEnum.NORMAL_STATUS.getBizStatusCode());
            tmPlatBizTmp.setRemark1(AuditStatusEnum.PUBLISH_AUDIT_PROCESSING.getAuditStatusCode());
            tmPlatBizTmp.setAuditStatus(AuditStatusEnum.PUBLISH_AUDIT_PASSED.getAuditStatusCode());
            tmPlatBizTmp.setOprTableEname(TableNameEnum.T_M_MC_MCHNT_INFO.getTableNameCode());
            tmPlatBizTmp.setMcStatus(McStatusEnum.PROGRESSING.getMcStatusCode());
            int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
            if (Database.DBS_SUCCESS != iReturnCode) {
                rglog.error("将法人机构号<{}>营销活动编号<{}>的机构编号<{}>的营销活动机构信息更新临时表失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), tmPlatBizTmp.getOrgId(), iReturnCode);
                return iReturnCode;
            }
        } else if (oprType.equals("manage")) {
            TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
            tmPlatBizTmp.setInstId(tmPlatBizTmpList.get(CommonConstant.ZERO).getInstId());
            tmPlatBizTmp.setMcNo(tmPlatBizTmpList.get(CommonConstant.ZERO).getMcNo());
            tmPlatBizTmp.setLastOprId(tmPlatBizTmpList.get(CommonConstant.ZERO).getLastOprId());
            tmPlatBizTmp.setLastUpdateTime(tmPlatBizTmpList.get(CommonConstant.ZERO).getLastUpdateTime());
            tmPlatBizTmp.setBizStatus(BizStatusEnum.NORMAL_STATUS.getBizStatusCode());
            tmPlatBizTmp.setRemark1(AuditStatusEnum.MODIFY_AUDIT_PROCESSING.getAuditStatusCode());
            tmPlatBizTmp.setAuditStatus(AuditStatusEnum.PUBLISH_AUDIT_PROCESSING.getAuditStatusCode());
            tmPlatBizTmp.setOprTableEname(TableNameEnum.T_M_MC_MCHNT_INFO.getTableNameCode());
            tmPlatBizTmp.setMcStatus(McStatusEnum.NOT_PUBLISHED.getMcStatusCode());
            int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
            if (Database.DBS_SUCCESS != iReturnCode) {
                rglog.error("将法人机构号<{}>营销活动编号<{}>的机构编号<{}>的营销活动机构信息更新临时表失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), tmPlatBizTmp.getOrgId(), iReturnCode);
                return iReturnCode;
            }
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 进行中商户新增查询是否已经新增查询
     *
     * @param tmPlatBizTmp 收银员返现活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMPlatBizTmp 业务数据临时表
     * @throws Exception 异常信息
     * @author JL PANG
     * @date 2020/7/4
     */
    @Override
    public List<TMPlatBizTmp> selectListByInstIdMcNoTableNameStatus(TMPlatBizTmp tmPlatBizTmp) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectListByInstIdMcNoTableNameStatus");

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (null == objectList || objectList.isEmpty()) {
            rglog.error("查询机构<{}>营销活动<{}>所有待审批数据失败!", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo());
            return null;
        }

        return objectList.stream().map(item -> (TMPlatBizTmp) (item)).collect(Collectors.toList());
    }

    /**
     * 删除临时表进行中商户
     *
     * @param tmPlatBizTmp 临时表
     * @return int
     * @throws Exception
     * @author JL PANG
     * @date 2020/7/10 01:28
     */
    @Override
    public int deleteByStatusTablename(TMPlatBizTmp tmPlatBizTmp) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "deleteByStatusTablename");

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode && Database.DBS_NOT_FOUND != iReturnCode) {
            rglog.error("根据条件删除法人机构号<{}>营销活动编号<{}>所有临时表数据失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return CommonConstant.PROCESS_FAILED;
        }

        return CommonConstant.PROCESS_SUCCESS;
    }

    /**
     * 删除临时表进行中商户
     *
     * @param tmPlatBizTmpList 临时表
     * @return int
     * @throws Exception
     * @author JL PANG
     * @date 2020/7/10 01:28
     */
    @Override
    public int deleteByMcNoMchntNoTablename(List<TMPlatBizTmp> tmPlatBizTmpList) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "deleteByMcNoMchntNoTablename");
        for (TMPlatBizTmp tmPlatBizTmp : tmPlatBizTmpList) {
            int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
            if (Database.DBS_SUCCESS != iReturnCode && Database.DBS_NOT_FOUND != iReturnCode) {
                rglog.error("根据条件删除法人机构号<{}>营销活动编号<{}>所有临时表数据失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
                return CommonConstant.PROCESS_FAILED;
            }
        }
        return CommonConstant.PROCESS_SUCCESS;
    }

    /**
     * 进行中添加商户查询指定活动下各种拒绝状态下的商户
     *
     * @param instId 法人机构号
     * @param mcNo   活动编号
     * @return cc.rengu.igas.momp.common.entity.TMPlatBizTmp 业务数据临时表
     * @throws Exception 异常信息
     * @author JL Pang
     * @date 2020/9/7 14:14
     */
    @Override
    public List<TMPlatBizTmp> selectMchntByInstIdMcNo(String instId, String mcNo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMchntByInstIdMcNo");
        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
        tmPlatBizTmp.setInstId(instId);
        tmPlatBizTmp.setMcNo(mcNo);
        tmPlatBizTmp.setOprTableEname(TableNameEnum.T_M_MC_MCHNT_INFO.getTableNameCode());

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (null == objectList || objectList.isEmpty()) {
            rglog.error("查询机构<{}>营销活动<{}>进行中添加商户已被拒绝的商户数据失败!", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo());
            return null;
        }

        return objectList.stream().map(item -> (TMPlatBizTmp) (item)).collect(Collectors.toList());
    }

    /**
     * 进行中添加商户查询指定活动下各种拒绝状态下的商户
     * 分页查询接口
     *
     * @param instId   机构编号入参
     * @param mcNo     活动编号入参
     * @param pageInfo 分页信息入参
     * @return cc.rengu.oltp.utility.bean.PageResult 分页数据
     * @throws Exception 异常信息
     * @author 800P_sunbzh01
     * @date 2021/8/12 13:27
     */
    @Override
    public PageResult selectMchntByInstIdMcNo(String instId, String mcNo, PageInfo pageInfo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMchntByInstIdMcNo");
        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
        tmPlatBizTmp.setInstId(instId);
        tmPlatBizTmp.setMcNo(mcNo);
        tmPlatBizTmp.setOprTableEname(TableNameEnum.T_M_MC_MCHNT_INFO.getTableNameCode());

        return dbsUtil.dbsFetchPageListData(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class, pageInfo);
    }

    /**
     * 更新临时表进行中商户
     *
     * @param tmPlatBizTmp 临时表
     * @return int
     * @throws Exception
     * @author JL PANG
     * @date 2020/7/10 01:28
     */
    @Override
    public int updateByInstIdMchntNoMcNo(TMPlatBizTmp tmPlatBizTmp) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateByInstIdMchntNoMcNo");
        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode && Database.DBS_NOT_FOUND != iReturnCode) {
            rglog.error("根据条件更新法人机构号<{}>营销活动编号<{}>所有临时表数据失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return CommonConstant.PROCESS_FAILED;
        }
        return CommonConstant.PROCESS_SUCCESS;
    }

    @Override
    public int updataTMPlatBizByinstIdMcNoTableNameStatus(TMPlatBizTmp tmPlatBizTmp) throws Exception {
        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updataTMPlatBizByinstIdMcNoTableNameStatus");
        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode && Database.DBS_NOT_FOUND != iReturnCode) {
            rglog.error("根据条件更新法人机构号<{}>营销活动编号<{}>所有临时表数据失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return CommonConstant.PROCESS_FAILED;
        }
        return CommonConstant.PROCESS_SUCCESS;
    }

    @Override
    public int updataTMPlatBizByinstIdMcNoTableNameOnlyStatus(TMPlatBizTmp tmPlatBizTmp) throws Exception {
        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updataTMPlatBizByinstIdMcNoTableNameOnlyStatus");
        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode && Database.DBS_NOT_FOUND != iReturnCode) {
            rglog.error("根据条件更新法人机构号<{}>营销活动编号<{}>所有临时表数据失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return CommonConstant.PROCESS_FAILED;
        }
        return CommonConstant.PROCESS_SUCCESS;
    }


    @Override
    public int updataTMPlaAuditStatusForMchntTask(String instId, String mcNo, String auditStatus, String tableName) throws Exception {
        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updataTMPlaAuditStatusForMchntTask");
        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
        tmPlatBizTmp.setInstId(instId);
        tmPlatBizTmp.setMcNo(mcNo);
        tmPlatBizTmp.setAuditStatus(auditStatus);
        tmPlatBizTmp.setOprTableEname(tableName);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode && Database.DBS_NOT_FOUND != iReturnCode) {
            rglog.error("根据条件更新法人机构号<{}>营销活动编号<{}>所有临时表数据失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return CommonConstant.PROCESS_FAILED;
        }
        return CommonConstant.PROCESS_SUCCESS;
    }

    @Override
    public int deletePlatBizTmpByMchntType(String instId, String mcNo, String mchntType) throws Exception {
        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "deletePlatBizTmpByMchntType");
        TMPlatBizTmp tmPlatBizTmp = new TMPlatBizTmp();
        tmPlatBizTmp.setInstId(instId);
        tmPlatBizTmp.setMcNo(mcNo);
        tmPlatBizTmp.setRemark1(mchntType);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmPlatBizTmp, TMPlatBizTmp.class);
        if (Database.DBS_SUCCESS != iReturnCode && Database.DBS_NOT_FOUND != iReturnCode) {
            rglog.error("根据条件更新法人机构号<{}>营销活动编号<{}>所有临时表数据失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
            return CommonConstant.PROCESS_FAILED;
        }
        return CommonConstant.PROCESS_SUCCESS;
    }

}
